﻿using Nasty.Core.Attributes;
using Newtonsoft.Json;
using SqlSugar;

namespace Nasty.Core.Entity.Flow
{
    [SugarTable("SysFlowLog", TableDescription = "流程日志")]
    public class FlowLog : StandardEntity<Flow>
    {
        /// <summary>
        /// 流程Id
        /// </summary>
        [SugarColumn(ColumnName = "FlowId", IsOnlyIgnoreUpdate = true, ColumnDescription = "位置Y")]
        public string? FlowId { get; set; }

        /// <summary>
        /// 节点Id
        /// </summary>
        [NastyColumn(ColumnName = "NodeId", IsOnlyIgnoreUpdate = true, ColumnDescription = "节点Id", Required = true)]
        public string? NodeId { get; set; }

        /// <summary>
        /// 节点名称
        /// </summary>
        [NastyColumn(ColumnName = "NodeName", IsOnlyIgnoreUpdate = true, ColumnDescription = "节点名称", Required = true)]
        public string? NodeName { get; set; }

        /// <summary>
        /// 节点编码
        /// </summary>
        [NastyColumn(ColumnName = "NodeCode", IsOnlyIgnoreUpdate = true, ColumnDescription = "节点编码", Required = true)]
        public string? NodeCode { get; set; }

        /// <summary>
        /// 用户Id
        /// </summary>
        [NastyColumn(ColumnName = "UserId", IsOnlyIgnoreUpdate = true, ColumnDescription = "用户Id", Required = true)]
        public string? UserId { get; set; }

        /// <summary>
        /// 用户名称
        /// </summary>
        [NastyColumn(ColumnName = "UserName", IsOnlyIgnoreUpdate = true, ColumnDescription = "用户名称", Required = true)]
        public string? UserName { get; set; }


        /// <summary>
        /// 节点动作
        /// </summary>
        [NastyColumn(ColumnName = "Action", IsOnlyIgnoreUpdate = true, ColumnDescription = "节点动作", Required = true)]
        public FlowLogAction Action { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [SugarColumn(ColumnName = "Remark", IsOnlyIgnoreUpdate = true, ColumnDescription = "备注")]
        public string Remark { get; set; }

        public override void OnPreAdd()
        {
            base.OnPreAdd();
        }
    }

    public enum FlowLogAction : byte
    {
        /// <summary>
        /// 同意
        /// </summary>
        Agree = 1,
        /// <summary>
        /// 驳回
        /// </summary>
        Reject = 2,
        /// <summary>
        /// 委托
        /// </summary>
        Delegate = 3,
        /// <summary>
        /// 撤销 = 删除
        /// </summary>
        Revoke = 9
    }
}
